Method and system for denoising and demosaicing artifact suppression in digital images

ABSTRACT

Methods and systems for denoising a digital image are provided. The method includes determining first and second plurality of pixel patches including respective first (p) and second (q) pixels, determining a patch distance between each pair of corresponding pixel patches in the first plurality and the second plurality of pixel patches, determining an effective distance between the first pixel (p) and the second pixel (q), repeating the above steps for the same first pixel (p) and another second pixel (q) until a predetermined number of pixels (q) in the raw digital image is processed, and then denoising the first pixel (p), including determining respective contributions of the pixels (q) into a noise reduction of the pixel (p), using respective effective distances of the pixels (q). A corresponding system is also provided. Embodiments of the invention provide computational advantages for denoising digital images.

FIELD OF THE INVENTION

The present invention generally relates to image processing of digitalimages, and in particular to a method and system for denoising anddemosaicing raw digital images.

BACKGROUND OF THE INVENTION

Digital images may become noisy during acquisition or transmission,resulting in the reduced quality of the digital images.

Reducing the noise, or denoising, of the digital image still remains achallenge, because noise reduction introduces artifacts and causesblurring of digital images.

There are various existing denoising techniques, each having itsassumptions, advantages, and limitations, and being suitable toparticular noise model.

Accordingly, there is a need in the industry for developing analternative method and system for denoising digital images, which wouldmitigate or avoid at least some shortcomings of the prior art.

Also, because digital images are acquired by an image sensor overlaidwith a color filter array (CFA), for example a Bayer's filter, ademosaicing process is needed to remove demosaic artifacts resultingfrom the CFA structure of sensors, to render the digital images into aviewable format. Demosaicing process is also known as CFA interpolationor color reconstruction. Modern digital cameras can save digital imagesin a raw format to obtain raw images, allowing users to demosaic rawimages using software, instead of using a firmware built-in the digitalcamera.

Usually, demosaicing methods cause several artifacts such as zippereffect and color artifact which are easily seen around edges and denselytextured regions, and typically new demosaicing methods are proposed toremove or mitigate these artifacts. A survey in “Image Demosaicing: ASystematic Survey,” X. Li, B. Gunturk, L. Zhang., Proc. SPIE 6822,Visual Communications and Image Processing 2008, provides a review ofdemosaicing methods.

Accordingly, there is a need in the industry for developing analternative method and system for suppressing artifacts in digitalimages introduced by existing demosaicing methods, which would mitigateor avoid at least the shortcomings of the prior art.

SUMMARY OF THE INVENTION

There is an object of the present invention to provide an improvedmethod and system for denoising and demosaic artifact suppression ofdigital images, which would mitigate or avoid at least somedisadvantages of the prior art.

A system of one or more computers can be configured to performparticular operations or actions by virtue of having software, firmware,hardware, or a combination of them installed on the system that inoperation causes or cause the system to perform the actions. One or morecomputer programs can be configured to perform particular operations oractions by virtue of including instructions that, when executed by dataprocessing apparatus, cause the apparatus to perform the actions.

One general aspect includes a method for denoising a raw digital image,including: employing a hardware processor to perform: (a) selecting afirst pixel (p) of the raw digital image; (b) selecting a second pixel(q) of the raw digital image; (c) determining a first plurality of pixelpatches, each pixel patch in the first plurality of pixel having apredetermined pixel patch shape and a predetermined pixel patch size andcontaining the first pixel (p); (d) determining a second plurality ofpixel patches, each pixel patch in the second plurality containing thesecond pixel (q), and corresponding in shape and size to a respectivepixel patch of the first plurality; (e) determining a patch distancebetween each pair of corresponding pixel patches in the first pluralityand the second plurality of pixel patches; (f) determining an effectivedistance between the first pixel (p) and the second pixel (q) based ondetermined patch distances for all pairs of corresponding pixel patchesin the first plurality and the second plurality of pixel patches; (g)repeating the steps (a) to (f) for the same first pixel (p) and anothersecond pixel (q) until a predetermined number of pixels (q) in the rawdigital image is processed; and (h) denoising the first pixel (p),including determining respective contributions of the pixels (q) into anoise reduction of the pixel (p), using respective effective distancesof the pixels (q). Other embodiments of this aspect includecorresponding computer systems, apparatus, and computer programsrecorded on one or more computer storage devices, each configured toperform the actions of the methods.

Implementations of the method may include one or more of the followingfeatures. The method including repeating the steps (a) to (h) for otherfirst pixels (p) until a predetermined number of pixels (p) in the rawdigital image is processed, thereby obtaining a denoised raw digitalimage. The method where: the predetermined number of pixels (q) includesall pixels (q) in the raw digital image outside of the first pluralityof pixel patches; and the predetermined number of pixels (p) includesall pixels (p) in the raw digital image outside of the second pluralityof pixel patches. The method where the predetermined pixel patch shapeis one of the following: a square; a rectangle; a circle; an oval; ahexagon; an octagon; or a polygon. The method where the predeterminedpixel patch shape is a square, and a predetermined pixel patch size isfrom 2×2 pixels to 3×3 pixels. The method where the predetermined pixelpatch shape is a square, and a predetermined pixel patch size is fromabout 2×2 pixels to about 8×8 pixels. The method where the predeterminedpixel patch shape is a square, and a predetermined pixel patch size isfrom about 5×5 pixels to about 16×16 pixels. The method where the step(f) includes determining the effective distance as an average patchdistance among all patch distances. The method where the step (f)includes determining the effective distance as a maximum patch distanceamong all patch distances. The method where the denoising includesapplying one of: a non-local means method; or a bilateral filter method.The method where: the predetermined shape of the pixel patch is arectangle; a neighborhood of pixels surrounding the pixel (p) used fordenoising the pixel (p) has a rectangular shape; and the denoisingcomprising applying an integral images method. The method where the rawdigital image is a Bayer's pattern image. The method where the steps (a)and (b) include selecting the first and second pixels of a same type.The method further including removing high frequency artifacts from thefirst pixel (p), including: determining an average for each pixel patchin the first plurality of pixels; forming a multi-dimensional guide forthe first pixel (p), including the average for the pixel patches ascomponents of the multi-dimensional guide; and applying a bilateralfilter method with the multi-dimensional guide to the first pixel (p),thereby removing the high frequency artifacts. The system where theinstructions cause the processor to repeat the steps (a) to (h) forother first pixels (p) until a predetermined number of pixels (p) in theraw digital image is processed, thereby obtaining a denoised raw digitalimage. The system where: the predetermined number of pixels (q) includesall pixels (q) in the raw digital image outside of the first pluralityof pixel patches; and the predetermined number of pixels (p) includesall pixels (p) in the raw digital image outside of the second pluralityof pixel patches. The system where the predetermined pixel patch shapeis one of the following: a square; a rectangle; a circle; an oval; ahexagon; an octagon; or a polygon. The system where the predeterminedpixel patch shape is a square, and a predetermined pixel patch size isfrom 2×2 pixels to 3×3 pixels. The system where the predetermined pixelpatch shape is a square, and a predetermined pixel patch size is fromabout 2×2 pixels to about 8×8 pixels. The system where the predeterminedpixel patch shape is a square, and a predetermined pixel patch size isfrom about 5×5 pixels to about 16×16 pixels. The system where the step(f) includes determining the effective distance as an average patchdistance among all patch distances. The system where the step (1)includes determining the effective distance as a maximum patch distanceamong all patch distances. The system where the instructions cause theprocessor to apply one of: a non-local means method; or a bilateralfilter method, to denoise the first pixel (p). The system where: thepredetermined shape of the pixel patch is a rectangle; a neighborhood ofpixels surrounding the pixel (p) used for denoising the pixel (p) has arectangular shape; and the denoising comprising applying an integralimages method. The system where the raw digital image is a Bayer'spattern image. The system where the instructions cause the processor toselect the first and second pixels of a same type in steps (a) and (b).The system the instructions further cause the processor to remove highfrequency artifacts from the first pixel (p), the instructions cause theprocessor to: determine an average for each pixel patch in the firstplurality of pixels; form a multi-dimensional guide for the first pixel(p), including the average for the pixel patches as components of themulti-dimensional guide; and apply a bilateral filter method with themulti-dimensional guide to the first pixel (p), thereby removing thehigh frequency artifacts. Implementations of the described techniquesmay include hardware, a method or process, or computer software on acomputer-accessible medium.

Another general aspect includes a system for denoising a raw digitalimage, including: a processor and a non-transitory computer readablestorage medium having computer readable instructions stored thereon forexecution by the processor, causing the processor to: (a) select a firstpixel (p) of the raw digital image; (b) select a second pixel (q) of theraw digital image; (c) determine a first plurality of pixel patches,each pixel patch in the first plurality of pixels having a predeterminedpixel patch shape and a predetermined pixel patch size and containingthe first pixel (p); (d) determine a second plurality of pixel patches,each pixel patch in the second plurality containing the second pixel(q), and corresponding in shape and size to a respective pixel patch ofthe first plurality; (e) determine a patch distance between each pair ofcorresponding pixel patches in the first plurality and the secondplurality of pixel patches; (f) determine an effective distance betweenthe first pixel (p) and the second pixel (q) based on determined patchdistances for all pairs of corresponding pixel patches in the firstplurality and the second plurality of pixel patches; (g) repeat thesteps (a) to (1) for the same first pixel (p) and another second pixel(q) until a predetermined number of pixels (q) in the raw digital imageis processed; and (h) denoise the first pixel (p), including determiningrespective contributions of the pixels (q) into a noise reduction of thepixel (p), using respective effective distances of the pixels (q). Otherembodiments of this aspect include corresponding computer systems,apparatus, and computer programs recorded on one or more computerstorage devices, each configured to perform the actions of the methods.

Implementations of the system may include one or more of the followingfeatures. The system where the instructions cause the processor torepeat the steps (a) to (h) for other first pixels (p) until apredetermined number of pixels (p) in the raw digital image isprocessed, thereby obtaining a denoised raw digital image. The systemwhere: the predetermined number of pixels (q) includes all pixels (q) inthe raw digital image outside of the first plurality of pixel patches;and the predetermined number of pixels (p) includes all pixels (p) inthe raw digital image outside of the second plurality of pixel patches.The system where the predetermined pixel patch shape is one of thefollowing: a square; a rectangle; a circle; an oval; a hexagon; anoctagon; or a polygon. The system where the predetermined pixel patchshape is a square, and a predetermined pixel patch size is from 2×2pixels to 3×3 pixels. The system where the predetermined pixel patchshape is a square, and a predetermined pixel patch size is from about2×2 pixels to about 8×8 pixels. The system where the predetermined pixelpatch shape is a square, and a predetermined pixel patch size is fromabout 5×5 pixels to about 16×16 pixels. The system where the step (f)includes determining the effective distance as an average patch distanceamong all patch distances. The system where the step (f) includesdetermining the effective distance as a maximum patch distance among allpatch distances. The system where the instructions cause the processorto apply one of: a non-local means method; or a bilateral filter method,to denoise the first pixel (p). The system where: the predeterminedshape of the pixel patch is a square; and the denoising includingapplying an integral images method. The system where the raw digitalimage is a Bayer's pattern image. The system where the instructionscause the processor to select the first and second pixels of a same typein steps (a) and (b). The system the instructions further cause theprocessor to remove high frequency artifacts from the first pixel (p),the instructions cause the processor to: determine an average for eachpixel patch in the first plurality of pixels; form a multi-dimensionalguide for the first pixel (p), including the average for the pixelpatches as components of the multi-dimensional guide; and apply abilateral filter method with the multi-dimensional guide to the firstpixel (p), thereby removing the high frequency artifacts.Implementations of the described techniques may include hardware, amethod or process, or computer software on a computer-accessible medium.

Denoising

According to one embodiment of the invention, a method and system fordenoising digital images are provided, where a Non-Local Means filter ismodified to take into account a color filter pattern of an image sensor.In particular, only pixels of the same color are averaged together andprocessed by the Non-Local Means filter. In an embodiment of theinvention, the color filter array is a Bayer's filter. A repetitivepattern of the Bayer's filter is taken into account, and the Non-LocalMeans method is modified to search only for every other row and everyother column when matching neighborhoods of pixels, thus processing onlypixels of the same color. As a result, the quality of denoising has beenimproved.

Demosaic Artifact Suppression

According to another embodiment of the present invention, a method isprovided that is used as a post processing of the demosaiced image. Incontrast to the prior art methods, where usually an edge detection isexplicitly performed, the method of the another embodiment of thepresent invention performs an image restoration without any explicitedge detection. The method of the another embodiment of the presentinvention attenuates or removes demosaic artifacts that appear asrepetitive patterns known as zipper artifacts, however it is notapplicable to removing color artifacts, introduced by some demosaicers.

The method applies the cross bilateral filter with improved guide on theRGB image, where the improved guide of the cross bilateral filter iscarefully chosen to take advantage of the regular patterns typicallyseen in demosaicing artifacts. The cross bilateral filter, also known asjoint bilateral filter, has been described in “Flash PhotographyEnhancement Via Intrinsic Relighting,” E. Eisemann and F. Durand, ACMTrans. on Graphics, vol. 23, no. 3, pp. 673-678, August 2004 and“Digital Photography With Flash And No-Flash Image Pairs,” G.Petschnigg, R. Szeliski, M. Agrawala, M. Cohen, H. Hoppe, and K. Toyama,ACM Trans. on Graphics, vol. 23, no. 3, pp. 664-672, Aug. 2004, and adetailed description of the bilateral filter and its extensions isprovided in “Bilateral Filtering: Theory And Applications,” S. Paris, P.Kornprobst, J. Tumblin, and F. Durand, Foundations and Trends inComputer Graphics and Vision, vol. 4, no. 1, pp. 1-75, 2009.

The guide that is used in cross bilateral filter, for performingdemosaic artifact suppression, is a 4 channel image, which can also beseen as a function that maps each pixel of the digital image to a 4dimensional vector. The guide is computed during the filtering process,or precomputed before filtering, as follows. For each pixel p weconsider the 4 blocks of 2 by 2 pixels that contain a pixel of interestp. We compute the average luminance on each of those 2×2 blocks to get afour dimensional feature vector corresponding to the pixel p. The4-dimensional vector gives 4 values for the guide corresponding to thepixel p.

The effect of cross bilateral filtering is to make intensities of twopixels p and q more similar if their corresponding four dimensionalfeature vectors in the guide are similar, and p and q are spatiallyclose enough.

In the embodiments of the present invention, the improved guide based onthe four dimensional feature vector is used in the cross bilateralfilter, for performing artifact suppression on the demosaiced image.Thus, an improved cross bilateral filter having an improved guide of theembodiment of the present invention, has been provided.

In an area where the demosaiced image should be uniform, manydemosaicers typically produce a non-uniform image, for example, thedemosaiced image exhibits repetitive patterns where two neighboringblocks of 2×2 pixels are symmetric with respect to one another.

In particular, neighboring blocks of 2×2 pixels have approximately thesame mean intensity, when the underlying true image is actually uniform.The same considerations also apply for an area of the demosaiced imagewhere there is an edge with a slope that is approximately a multiple of45 degrees. Two 2×2 pixel blocks that are neighbors along the directionof the edge have approximately the same mean intensities. While theaverage of the 2×2 pixel blocks are similar, pixel values are not,because of the zipper artifact, even though they should similar.

The cross bilateral filter takes the advantage of the similarity of theaverage luminance of the 2×2 pixel blocks, to make those pixels moresimilar.

Thus, improved methods and system for denoising and demosaic artifactsuppression in digital images have been provided.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments of the invention will now be described, by way of example,with reference to the accompanying drawings, in which:

FIG. 1 illustrates a system for denoising of digital images according toan embodiment of the invention;

FIG. 2 illustrates a color filter array (CFA) Pattern Aware Denoisingmodule of FIG. 1 in more detail;

FIG. 3A shows a flowchart illustrating a method for denoising of digitalimages according to an embodiment of the present invention;

FIG. 3B shows a flowchart illustrating a method for denoising of digitalimages according to another embodiment of the present invention;

FIG. 3C shows a flowchart illustrating a method of a step in theflowchart shown in FIG. 3B;

FIG. 4 illustrates a system for demosaic artifact suppression in digitalimages according to yet another embodiment of the invention;

FIG. 5 illustrates a Demosaic Artifact Suppression Module of FIG. 4 inmore detail; and

FIG. 6 shows a flowchart illustrating a method for demosaic artifactsuppression in digital images according to the yet another embodiment ofthe present invention.

DESCRIPTION OF EMBODIMENTS OF THE INVENTION Glossary

Bayer Filter Mosaic: a color filter array (CFA) for arranging RGB colorfilters on a square grid of photo sensors. Bayer Filter Mosaic isdescribed in an article titled “Bayer filter”, which is publishedon-line by Wikipedia, downloaded 16 Mar. 2017, and which is submitted inthe information disclosure statement for the present application, theentire contents of the article being incorporated herein by reference.

Bilateral Filter: a non-linear, edge-preserving and noise-reducingsmoothing filter for images. The intensity value at each pixel in animage is replaced by a weighted average of intensity values from nearbypixels. Bilateral Filters are described in an article titled “BilateralFilter”, which is published on-line by Wikipedia, downloaded 16 Mar.2017, and which is submitted in the information disclosure statement forthe present application, the entire contents of the article beingincorporated herein by reference.

Non-local Means: an algorithm in image processing for image denoising.Unlike “local mean” filters, which take the mean value of a group ofpixels surrounding a target pixel to smooth the image, non-local meansfiltering takes a mean of all pixels in the image, weighted by howsimilar these pixels are to the target pixel. Non-local Means isdescribed in an article titled “Non-local Means”, which is publishedon-line by Wikipedia, downloaded 16 Mar. 2017, and which is submitted inthe information disclosure statement for the present application, theentire contents of the article being incorporated herein by reference.

Raw Image: a file that contains minimally processed data from the imagesensor of either a digital camera, image scanner, or motion picture filmscanner. Raw Images are described in an article titled “Raw imageformat”, which is published on-line by Wikipedia, downloaded 16 Mar.2017, and which is submitted in the information disclosure statement forthe present application, the entire contents of the article beingincorporated herein by reference.

Integral Image (also known as a summed area table): a data structure andalgorithm for quickly and efficiently generating the sum of values in arectangular subset of a grid. Integral Images are described in anarticle titled “Summed area table”, which is published on-line byWikipedia, downloaded 16 Mar. 2017, and which is submitted in theinformation disclosure statement for the present application, the entirecontents of the article being incorporated herein by reference.

Demosaicing (also referred to as de-mosaicing, demosaicking ordebayering) algorithm: a digital image process used to reconstruct afull color image from the incomplete color samples output from an imagesensor overlaid with a color filter array (CFA). It is also known as CFAinterpolation or color reconstruction. Demosaicing is described in anarticle titled “Demosaicing”, which is published on-line by Wikipedia,downloaded 16 Mar. 2017, and which is submitted in the informationdisclosure statement for the present application, the entire contents ofthe article being incorporated herein by reference.

Anscombe Transform: a variance-stabilizing transformation thattransforms a random variable with a Poisson distribution into one withan approximately standard Gaussian distribution. The Anscombe Transformis described in an article titled “Anscombe Transform”, which ispublished on-line by Wikipedia, downloaded 16 Mar. 2017, and which issubmitted in the information disclosure statement for the presentapplication, the entire contents of the article being incorporatedherein by reference.

Neighborhood of pixel p N(p): Set of pixels surrounding pixel p whichvalues are used to denoise pixel p.

Patch diameter or radius M: This measures the span in pixels, in eachdimension, of the patches that are considered around each pixels tocompute the weights in the averaging formulas. In section 1, M is theradius of the patch, i.e. a patch is a square of (2M+1)×(2M+1) pixels,while in section 2 M is the diameter of the patch, i.e. a patch is asquare of M×M pixels.

Patch kernel: The subscript p stands for “patch”, it is not related topixel p. That function can weight pixels in the patch differentlydepending on their positions within the patch. It allows for example tohave disc shaped patches. It can also be used to give less weights topixels that are more distant to the centre of the patch, for instance byusing a Gaussian kernel.

Patch distance between pixels p and q: This is a similarity measurebetween the pixels surrounding p and the pixels surrounding q (includingpixels p and q). It does not satisfy the mathematical definition of adistance, but with a slight abuse of terminology we still call it adistance.

Neighborhood half radius K: This measures the size of the neighborhoodN(p), which is a square of (4k+1)×(4k+1) pixels.

“h”: The physical meaning of “h” is denoising strength. It is a positivevalue. The higher it is the stronger the denoising is, meaning morenoise is removed at the risk of losing some details, and conversely thelower it is the more details are preserved, at the risk of letting stillsome remaining noise or possibly creating some artifacts.

“ρ”: the strength of a high frequency artifact removal filter (which iscomparable to h, the strength of the denoiser). The larger it is themore effective it is to remove noise. If it is set to a high value thenfine details may disappear.

1.0 Denoising of Digital Images

A system 100 for denoising of digital images of an embodiment of theinvention is shown in FIG. 1. The system 100 comprises a Raw ImageAcquisition Device 20, for example a digital camera, image scanner ormotion picture film scanner comprising an image sensor device 114 suchas CCD (charge coupled device) or CMOS (complementary metal oxidesemiconductor) image sensor, for acquiring a raw image 13. The raw image104 contains minimally processed data from the image sensor 21, in a rawimage format.

The acquired raw image 104 is supplied to an Image Processing Module 102comprising a CFA (color filter array) Pattern Aware Denoising Module 106for processing the raw image 104 into a denoised image 108. The CFAPattern Aware Denoising Module 106 takes into account thestructure/pattern of the CFA filter. In a preferred embodiment of theinvention, the CFA is a Bayer's filter having a Bayer's pattern. Thedescription of embodiments herein is formulated for Bayer CFA but it isequally applicable for any arbitrary CFA, for exampleRed-Green-Blue-Infrared or Red-Clear-Clear-Green.

The Image Processing Module 102 and CFA Pattern Aware Denoising Module106 are stored in a non-transitory computer readable memory device 118and comprise computer executable instructions stored in the memorydevice 118 for execution by a hardware processor 110. The CFA PatternAware Denoising Module 106 outputs the denoised image 108 through aDenoised Image Output Module 116 which contains computer readableinstructions stored in a memory (not shown) and is responsible forstorage or further processing of the denoised image 108 or transmissionof the denoised image 108 over a network.

FIG. 2 shows the CFA Pattern Aware Denoising Module 106 of FIG. 1 inmore detail.

In the embodiment of the invention, the CFA is a Bayer's filter. The CFAPattern Aware Denoising Module 106 comprises an Undenoised Pixel TypeSelection Module 202 for selecting a respective pixel type (such as Red,Green, Blue); an Undenoised Block Selection Module 206 for selecting 2×2blocks of pixels containing a pixel “p” of interest; an Undenoised PixelSelection Module 210 for selecting pixels to be denoised; and a ModifiedPatch Based Filtering Module 214 for applying a modified Non-Local Means(NLM) filter of the embodiment of the invention, or a patch basedfilter, or a bilateral filter, for denoising the pixel “p” of interest.The Pattern Aware Denoising Module 106 preferably includes a HighFrequency Filtering Module 218 which is described in detail hereinbelow. The Pattern Aware Denoising Module 106 also preferably includesan edge denoising module 220 which is described in detail herein below.The Pattern Aware Denoising Module 106 also preferably includes an imageblending module 222 which is described in detail herein below.

It is understood that other types of CFA are also possible, and the NLMfilter may be generally substituted by a patch based filter or abilateral filter suitable for processing a raw image obtained accordingto a respective CFA.

The Undenoised Pixel Type Selection Module 202, the Undenoised BlockSelection Module 206, the Undenoised Pixel Selection Module 210, and theModified Patch Based Filtering Module 214 comprise computer readableinstructions stored in a memory for execution by the hardware processor110.

The method for denoising of digital images of the embodiment of theinvention is illustrated by a flowchart 300 of FIG. 3A.

Upon acquisition of the raw image 104 by the Raw Image AcquisitionDevice 112 (box 302), the method selects undenoised pixel type, whichhas not been processed yet (box 304). For Bayer's pattern, the pixeltype is (R, G1, G2, B), where R=red, G1=green1, G2=green2, and B=blue.

An example of the above method follows. For simplicity, it is assumedthat the first pixel type that has been selected is R.

Next, an undenoised Bayer's block of 2×2 pixels is selected, which hasnot been processed yet (box 306), followed by selection (box 308) ofundenoised pixel (“p”) of the selected pixel type (for example R) in theselected undenoised Bayer's block of 2×2 pixels.

Next, the selected pixel “p” is denoised by using a Non-Local Meansfilter or another patch based filter or bilateral filter (box 310),which is applied only to the pixels of the selected pixel type (forexample only to pixels R). This means searching for neighboring pixels“q” of the selected pixel type only. However, even though “p” and “q”are of the same type, when computing distance between their respectivepatches, we include all pixels of the two patches, regardless of theirtypes. Since “p” and “q” are of the same type, when taking thedifference of the two patches, only differences between pixels of thesame types are performed. For instance suppose pixel “p” is of type R,Bayer's pattern alignment is RGGB and we consider 3×3 patchessurrounding the pixel of interest. Then for both “p” and “q” the typesof the pixels of their respective patches are the same, as can be seenon the following Table 1:

The distance between the two patches would be:

d(p,q)²=(I(p ₁)−I(q ₁))²+(I(p ₂)−I(q ₂))²+(I(p ₃)−I(q ₃))²+(I(p ₄)−I(q₄))²+(I(p ₅)−I(q ₅))²+(I(p ₆)−I(q ₆))²+(I(p ₇)−I(q ₇))²+(I(p ₈)−I(q₈))²+(I(p)−I(q))²

Then, the next pixel of the same selected pixel type is selected in thenext Bayer's block (box 312). If the next Bayer's block is not the lastundenoised Bayer's block for the selected pixel type (exit “No” from box312), the method returns to box 306 for selecting the next Bayer's blockfor processing, containing the next pixel of the selected pixel type.

Otherwise, if the next Bayer's block is the last undenoised Bayer'sblock for the selected pixel type (exit “Yes” from box 302), the methodproceeds to checking if all pixel types have been processed (box 304).

Provided the pixel type is not the last undenoised pixel type (exit “No”from box 304), i.e. there are other remaining pixel types available forprocessing, the method returns to box 304 for selected the nextundenoised pixel type, for example, G1, G2 or B.

Otherwise, provided the pixel type is the last undenoised pixel type(exit “Yes” from box 304), the method outputs a denoised image 108,through the Denoised Image Output Module 116, and the method isterminated.

1.1 Method for Denoising of Digital Images

The method and system for denoising of digital images of the embodimentof the present invention is suitable for digital images which have arepetitive spatial structure, for CFA pattern in raw digital images.

As an example, we describe a method for performing denoising directly ona raw image having a Bayer's pattern. The method for denoising of theembodiment of the invention is an adaptation of the Non Local Means(NLM) method for a raw image.

A raw image with Bayer's pattern comprises blocks of 2 by 2 pixels. Twoof these pixels record the intensity of the green light, and theremaining two pixels record the intensity of red and blue light.

This means that using the prior art NLM method on a raw image would notmake sense because intensity values of lights of different colors wouldbe averaged together.

In the present application, the NLM algorithm has been modified to takeinto account the Bayer pattern. One way of doing this is to search onlyevery other row and every other column when matching the pixel patches.

Let I be the raw noisy image and Î be the resulting image afterdenoising, for each pixel p,

${\hat{I}(p)} = {\frac{1}{C(p)}{\sum\limits_{x = {- k}}^{k}\; {\sum\limits_{y = {- k}}^{k}{{I\left( {p + {2\left( {x,y} \right)}} \right)}{{\omega \left( {p,{p + {2\left( {x,y} \right)}}} \right)}.}}}}}$

In the embodiment of the invention, the difference with the prior artNLM algorithm is that we skip odd columns and odd rows, with respect tothe pixel of interest p, when we use the factor 2 in front of (x,y) inthe equation above.

The parameters in the above noted equation are defined as follows, i.e.

when

${p \neq q},{{\omega \left( {p,q} \right)} = {\exp \left( {- \frac{{d\left( {p,q} \right)}^{2}}{h^{2}}} \right)}},$

or the variation

${{\omega \left( {p,q} \right)} = {\exp \left( {- \frac{\max \left( {0,{{d\left( {p,q} \right)}^{2} - {2\; \sigma^{2}}}} \right)}{h^{2}}} \right)}},$

when

${p = q},{{\omega \left( {p,p} \right)} = {\max\limits_{{q \in {B{(p)}}},{q \neq p}}{\omega \left( {p,q} \right)}}},$

with

${{B(p)} = \left\{ {{{p + {2\left( {x,y} \right)}}{{- k} \leq x}},{y \leq k}} \right\}},{{C(p)} = {\sum\limits_{x = {- k}}^{k}\; {\sum\limits_{y = {- k}}^{k}{\omega \left( {p,{2\left( {x,y} \right)}} \right)}}}},{{d\left( {p,q} \right)}^{2} = {\sum\limits_{x = {- M}}^{M}\; {\sum\limits_{y = {- M}}^{M}{{K_{p}\left( {x,y} \right)}\left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}}}$

K_(p) is a positive weighting kernel that puts a different weight oneach pixel of the patch. It can be chosen uniform, such as K≡1, ordecreasing with distance from the pixel at the center of theneighborhood (for instance a Gaussian kernel).

M and k are small integers (typically M ∈ {1, . . . , 4} and k∈ {1, . .. 12}, h is a real number. Those constants are chosen depending on theprevalence of the noise in the image, the stronger the noise, the higherthey are. The constant σ is the standard deviation of the noise in casethe noise can be assumed to have uniform standard deviation across theimage.

2.0 Texture Preserving Denoising

We now describe another embodiment of the raw image denoiser. Thedifference with the original algorithm is in the way we compute thedistance d(p, q) between the patch of the pixel to be denoised p and thepatches of its neighboring pixels q ∈ N(p)={p+2(i,j); i, j ∈ {−K, . . ., K}} where integer K is a parameter (the neighborhood radius). That newway of computing the distance between patches allows better preservationof textures and fine details. In the original algorithm we compute d(p,q)²as the squared Euclidean distance between the 2 patches centered at pand q respectively, i.e.

${d_{orig}\left( {p,q} \right)}^{2} = {\sum\limits_{x = {- M}}^{M}\; {\sum\limits_{y = {- M}}^{M}{{K_{p}\left( {x,y} \right)}\left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}}$

The method for denoising of digital images of the embodiment of theinvention is illustrated by a flowcharts 350 and 360 of FIGS. 3B and 3Crespectively. The steps 352, 354, 356, 3370, and 372 are substantiallythe same as respective steps 302, 304, 306, 308, 312, and 314 asdescribed herein above. Step 360 is described in detail with referenceto FIG. 3C.

After box 356 on FIG. 3B, a first plurality of pixel patches, each pixelpatch in the first plurality of pixel having a predetermined pixel patchshape and a predetermined pixel patch size and containing the firstpixel (p) is determined, box 362;

Then determining a second plurality of pixel patches, each pixel patchin the second plurality containing the second pixel (q), andcorresponding in shape and size to a respective pixel patch of the firstplurality, box 364;

Then a patch distance between each pair of corresponding pixel patchesin the first plurality and the second plurality of pixel patches isdetermined, box 366;

Then an effective distance between the first pixel (p) and the secondpixel (q) based on determined patch distances for all pairs ofcorresponding pixel patches in the first plurality and the secondplurality of pixel patches is determined, box 368;

Then execution returns to box 370 on FIG. 3C.

2.1 Patch Distance for Texture Preserving Denoising

In the texture preserving version of the raw image denoiser we not onlyconsider the patches that are centered at p and q, but also all patchesthat are shifted by some offset and that still keep pixel p within thepatch. Then d(p, q)²in the texture preserving version of the denoiser isthe maximum of the squared distances between all pairs of shiftedpatches, with the same shift for both patches. Note that in this versionwe not only allow patches of odd size (like 3 by 3 pixels) but also ofeven size (like 2 by 2 pixels), in this setting, M denotes the patchsize (i.e. its diameter) while it denoted the patch radius in thedescription of the original algorithm and in the formula of d_(orig) (p,q)²above.

We are now going to give an explicit formula to compute the distanced(p, q) in the texture preserving version, to this end we introduce thefollowing notation:

δ(p, q, j)=Σ_(x=j−M+1) ^(j)Σ_(y=i−M+1) ^(i) K _(p)(x, y, i, j) (I(p+(x,y))−I(q+(x, y)))² With i, j ∈ {0, . . . , M−1}

δ(p, q, i, j) is the squared distance between patches shifted by offset(i, j) containing p and q. The function K_(p)can be used to make theshape of the patch different from a square (for example a disc-likeshape) by putting weight 1 to some pixels and weight 0 to the others. Itcan also be used to give more weight to some pixels than others. Pixelpatches are preferably square or rectangular, however it is understoodthat pixel patches of other shapes may be chosen, for example, circle,oval, hexagon, octagon, polygon, or patches of an arbitrary shape. UsingK_(p) (x, y, i, j)=1 is also acceptable and makes possible to speed upthe algorithm as described in section 2.5.

The squared distance between pixels p and q is computed by aggregatingall the δ(p, q, i, j) with an aggregation function A:

d(p,q)² =A(δ(p,q, 0,0), . . . , δ(p, q, 0,M−1), . . . , δ(p, q, 1,0), .. . , δ(p, q, M−1,M−1))

That aggregation function may be for example the mean or average acrossthe δ(p, q, i, j):

${d\left( {p,q} \right)}^{2} = {\frac{1}{\left( {M - 1} \right)^{2}}{\sum\limits_{i = 0}^{M - 1}\; {\sum\limits_{j = 0}^{M - 1}{\delta \left( {p,q,i,j} \right)}}}}$

The best aggregation for the purpose of preserving texture details isthe maximum function:

${d\left( {p,q} \right)}^{2} = {\max\limits_{i,{j \in {\{{0,\ldots \;,{M - 1}})}}}{\delta \left( {p,q,i,j} \right)}}$

2.2 Example With M=2

An example of distance computation is presented in Tables 2A, 2B, 2C,and 2D below for the 4 possible shifts when the patch size is M=2 andassuming K_(p)(x, y, i, j)=1.

δ(p, q, 0,0)=(I(p ₁)−I(q ₁))²+(I(p ₂)−I(q ₂))²+(I(p ₄)−I(q₄))²+(I(p)−I(q))²

δ(p, q , 0 ,1)=(I(p ₂)−I(q ₂))²+(I(p ₃)−I(q ₃))₂+(I(p)−I(q))₂+(I(p₅)−I(q ₅))²

δ(p, q, 1,0)=(I(p ₄)−I(q ₄))²+(I(p)−I(q))²+(I(p ₆)−I(q ₆))²+(I(p ₇)−I(q₇))²

δ(p, q, 1,1)=(I(p)−I(q))₂+(I(p ₅)−I(q ₅))₂+(I(p ₇)−I(q ₇))²+(I(p ₈)−I(q₈))²

2.3 Discussion of the Distance for Texture Preservation

This way of computing the distance between pixels helps to denoise morestrongly flat areas compared to textured areas. Hence it favors detailspreservation where there are details to be preserved and conversely doesa better cleaning of the image where there are less details. In atextured area, the highest δ(p, q, i, j) is likely to be especiallyhigh, since it is based on the difference between different features (ordifferent parts of the same feature). In a flat area, on the contrarythe patches roughly have the same score. This tends to make the distancelarger for textured areas than for flat areas, and then to make weightsw(p, q) smaller for textured areas than for flat areas. As a resultdenoising tends to be stronger for flat areas than for textured areas.

2.4 Overall Denoising Formula

The rest of the algorithm is identical to the original algorithm, justreplacing d(p, q)² by its alternative definition. The final formula tocompute the denoised pixel p is:

${{\overset{\circ}{I}(p)} = {\frac{1}{C(p)}{\sum\limits_{q \in {N{(p)}}}\; {{\exp \left( \frac{- {d\left( {p,q} \right)}^{2}}{h^{2}} \right)}{I(q)}\mspace{14mu} {with}}}}}\mspace{11mu}$$\; {{C(p)} = {\sum\limits_{q \in {N{(p)}}}{\exp \left( \frac{- {d\left( {p,q} \right)}^{2}}{h^{2}} \right)}}}$

h is the strength of the denoiser. Ranges of useful values forparameters are given at section 2.6.

Remark: By default N(p)={p+2(i, j); i, j ∈ {−K, . . . ,K}} but it isalso possible to choose a different shape for N(p), the only requirementis that it only contains pixels of the same Bayer type as pixel p. Forinstance a disc-like shape would be N(p)={p+2(i, j); i, j ∈ {−K, . . . ,K}, i²+j²≦K²}. Alternatively, the neighborhood shape may be a circle, anoval, a hexagon, an octagon, or a polygon, or any arbitrary shape.However a rectangular shape for N(p) has the advantage to make possibleto speed up the algorithm as described in section 2.5. In its mostgeneral form, a rectangular shape for N(p) would be:

N(p)={p+2(i, j); i ∈ {−K ₁ , . . . , K ₁ }, j ∈ {−K ₂ , . . . , K ₂}}with K ₁ and K ₂ positive integers.

2.5 Computational Complexity

A implementation of the above texture preserving version of the distancewould be significantly more expensive than the original version for agiven patch size. Computing δ(p, q, i, j) requires two nested loops of Miterations each, d(p, q) requires two nested loops of M iterations eachtoo, then the sum over q ∈ N(p) requires two nested loops of Niterations each. The computational complexity of the version of thetexture preserving denoiser is θ(N_(pix)K²M⁴) where N_(pix) is thenumber of pixels in the input image, while the complexity of theoriginal denoiser is θ(N_(pix)K²m²), so the texture preserving denoiserrequires M²times more computations.

However, in the case where K_(p)(x, y, i, j)=1 and N(p) has arectangular shape, multiple computations of the same squared differencebetween pixel intensities can be avoided by using the technic ofintegral images. Reference for integral image method: “Rapid ObjectDetection using a Boosted Cascade of Simple Features” P. Viola, M.Jones, CVPR 2001. In our case this technic would allow to reusecomputations of squared differences between pixel intensities acrossdistances of patches that contain the same pair of pixels.

In a more general case, for the integral image method to be applicable,both N(p) and pixel patches should be either square or rectangular, andit still works if only N(p) is square and the pixel patch isrectangular, and vice versa.

When patches are rectangular and N(p) is rectangular, the formulas are:

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{x = {j - M_{1} + 1}}^{j}\; {\sum\limits_{y = {i - M_{2} + 1}}^{i}\; \left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}$

with M₁≠M₂ and

N(p)={p+2(i, j); i ∈ {−K _(1,) . . . , K ₁ }, j ∈ {−K _(2,) . . . ,K ₂}}with K ₁ ≠K ₂.

When patches are squares and N(p) is rectangular, the formulas are:

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{x = {j - M + 1}}^{j}\; {\sum\limits_{y = {i - M + 1}}^{i}\; \left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}$

and

N(p)={p+2(i, j); i ∈ {−K _(1,) . . . , K ₁ }, j ∈ {−K _(2,) . . . , K₂}} with K ₁ ≠K ₂.

When patches are rectangular and N(p) is square, the formulas are:

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{x = {j - M_{1} + 1}}^{j}\; {\sum\limits_{y = {i - M_{2} + 1}}^{i}\; \left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}$

with M₁≠M₂ and

N(p)={p+2(i, j); i, j ∈ {K, . . . , K}}.

When patches are squares and N(p) is square, the formulas are:

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{x = {j - M + 1}}^{j}\; {\sum\limits_{y = {i - M + 1}}^{i}\; \left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}$

and

N(p)={p+2(i, j); i, j ∈ {−K, . . . , K}}.

The most general form for δ(p, q, i, j) that still allows to useintegral images is:

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{x = {j - M_{1} + 1}}^{j}\; {\sum\limits_{y = {i - M_{2} + 1}}^{i}\; \left( {{I\left( {p + \left( {x,y} \right)} \right)} - {I\left( {q + \left( {x,y} \right)} \right)}} \right)^{2}}}$

Remark: that K_(p) (x, y, i, j) is missing because it is taken asconstant 1 and in the bounds of the summations the constant positiveintegers M₁ and M₂ appear instead of just M, in order to allow anyrectangular patch instead of just square patches.

Actually patches are not square in this example because in the sum, thevariable x spans the integers from j−M1+1 to j, which are M1 differentvalues, and the variable y spans the integers from i−M2+1 to i, whichare M2 different values. So the height and the width of the patch aredifferent. So the rectangular shape of the patch is achieved here thanksto the different bounds of the sums rather than thanks to the kernel Kp,because in the case of a rectangular shape is simpler to express it thisway. Off course that trick cannot be used if we want a disc-like shape,in that case we would need to use Kp to achieve a disc like shape, buthere we only need a rectangular shape, so it is appropriate.

The most general form for N(p) that that still allows to use integralimages is:

N(p)={p+2(i, j); i ∈ {−K ₁ , . . . , K ₁ }, j ∈ {−K _(2,) . . . , K ₂}}with K ₁ and K ₂ positive integers.

The technic of integral images could be used on the whole image, in thatcase it takes the complexity down to θ(N_(pix)K₁K₂) for both theoriginal and the texture preserving denoisers. For reasons related tothe memory it could be impossible to do so, for instance with linebuffer architectures. Then the technic of integral images could still beused at the level of the neighborhood N(p) of each pixel p, in that caseit takes the complexity down to θ(N_(pix)K₁K₂M₁M₂) for the texturepreserving denoisers.

We derive computations for applying the technic of integral images tothe computations of distances at both the level of the neighborhood N(p)and the level of the whole image. For simplicity of notation we writethe derivation for the case M:=M₁=M₂ but this does not limit thegenerality of the algorithm to the case M₁≠M₂.

2.5.1 Integral Image at the Level of the Neighborhood N(p) of Pixel p

We first compute the following quantity:

ρ(p,q,y,j)=Σ_(x=j−M+1) ^(j)(I(p+(x,y))−I(q+(x, y)))² for all j ∈ {0, . .. , M−1} and y ∈ {−M+1, . . . , M−1}.

To compute it efficiently we use the following recurrence

ρ(p,q,y,j)=ρ(p,q,y,j−1)+(I(p+(j,y))−I(q+(j,y))²−(I(p+(j−M, y))−I(q+(j−M,y)))²

Then notice that

${\delta \left( {p,q,i,j} \right)} = {\sum\limits_{y = {i - M + 1}}^{i}\; {\rho \left( {p,q,y,j} \right)}}$

Then to compute efficiently δ(p,q,i,j) for all i, j ∈ {0, . . . , M−1}we use the following recurrence

δ(p, q, i, j)=δ(p, q, i−1, j)+ρ(p, q, i, j)−ρ(p, q, i−M, j)

Using the two recurrences allow to precompute all the δ(p,q,i,j), i, j ∈{0, . . . , M−1} with computational complexity θ(M²). This allows tohave a computational complexity on the whole image of θ(N_(pix)K²M²),which is the same as for the original raw image denoiser. In practice wemust take into account that the computational complexity has still amultiplicative constant such that there is a speed up with respect tothe implementation as soon as M≧3 but not for M=2. More precisely, thenumber of squared differences that are computed are M⁴ for theimplementation and (3M−2)² when using the technic of integral images atthe level of the neighborhood N(p) of pixel p.

2.5.2 Integral Image at the Level of the Whole Image

We first compute the following quantity:

${\rho^{\prime}\left( {p,q} \right)} = {\sum\limits_{x = {{- M} + 1}}^{0}\; \left( {{I\left( {p + \left( {x,0} \right)} \right)} - {I\left( {q + \left( {x,0} \right)} \right)}} \right)^{2}}$

for all pixels p in the image and for all pixels q ∈ N(p).

To compute it efficiently we use the following recurrence

ρ′(p,q)=ρ′(p−(1,0), q−(1,0))+(I(p)−I(q))²−(I(p−(M,0))−I(q−(M,0)))²

Then

${\delta \left( {p,q,0,0} \right)} = {\sum\limits_{y = {{- M} + 1}}^{0}\; {\rho^{\prime}\left( {{p + \left( {0,y} \right)},{q + \left( {0,y} \right)}} \right)}}$

To compute efficiently δ(p, q) for all pixel p in the image and for allq ∈ N(p) we use the following recurrence

δ(p,q, 0, 0)=δ(p−(0,1), q−(0,1),0,0)+ρ′(p,q)−ρ′(p−(0,M), q−(0,M))

Now δ(p, q, i, j) does not require any additional computation becauseδ(p, q, i, j)=δ(p+(j, i), q+(j, i), 0,0), so all δ(p, q, i, j) for alli, j ∈ (0, . . . ,M−1), all pixels p and all pixels q ∈ N(p) areprecomputed with computational complexity θ(N_(pix)). Finally, usingthose precomputed δ(p, q, i, j), the number of floating point operationsis θ(N_(pix)K²). The number of comparisons is still θ(N_(pix)K²M²)though, becaused

$\left( {p,q} \right)^{2} = {\max\limits_{i,{j \in {\{{0,\ldots \mspace{14mu},{M - 1}}\}}}}{\delta \left( {p,q,i,j} \right)}}$

requires to loop over i, j ∈ (0, . . . , M−1) even though the δ(p, q, i,j) are precomputed.

2.6 Ranges for Parameters

We give ranges of useful values for the parameters of the algorithm: K,M and h. For parameter h give one range for the case where an Anscombetransform has been applied to the input image before denoising on onehand and one range for the case where the Anscombe transform is not usedassuming the pixel values are normalized in the range [0, 1]. For eachparameter we give three nested ranges of increasing length frompreferred to less preferred. However it should be noted that thoseranges are only indicative and the preferred values for the parametersdepends on the camera, the rest of the ISP (image signal processor), thecomputational budget available, and the lighting conditions.

Then choose h ∈ [0.2,1.5]. Provided no transform has been applied andthe range of the input image is [0, 1] then choose h ∈ [0.001,0.3].

2.6.1 Preferred Ranges

In some preferred embodiments a value of K is chosen from a range ofabout 5 to 8 and a value of M is chosen from a range of about 2 to 3.Provided an Anscombe transform has been applied to the raw image 104, avalue of h is chosen from a range of about 0.2 to 1.5; otherwise a valueof h is chosen from a range of about 0.001 to 0.2.

2.6.2 Other Preferred Ranges

In other preferred embodiments a value of K is chosen from a range ofabout 3 to 12 and a value of M is chosen from a range of about 2 to 4.Provided an Anscombe transform has been applied to the raw image 104, avalue of h is chosen from a range of about 0.1 to 2.5; otherwise a valueof h is chosen from a range of about 0.001 to 0.3.

2.6.3 Still Other Preferred Ranges

In still other preferred embodiments a value of K is chosen from a rangeof about 1 to 16 and a value of M is chosen from a range of about 2 to5. Provided an Anscombe transform has been applied to the raw image 104,a value of h is chosen from a range of about 0.01 to 4; otherwise avalue of h is chosen from a range of about 0.001 to 0.2.

3.0 High Frequency Artifact Removal Filter

A denoised image may exhibit some high frequency artifacts in each ofthe Bayer channels. We present here a high frequency filter module 218,see FIG. 2, that attenuate those artifacts while still preserving thedetails of the image. It is similar to the demosaic artifact suppressionfilter described herein below, but applied independently on each Bayerchannel.

3.1 Filter Description

We now give the details of that high frequency artifact removal filter218. We first define an image guide for the filter as follows. For eachpixel p=(x, y)of the image I that enters the filter, we note:

Z(x, y, 1)=I(x, y)+I(x+2, y)+I(x, y−2)+I(x+2, y−2)

Z(x, y, 2)=I(x, y)+I(x−2, y)+I(x, y+2)+I(x−2, y+2)

Z(x, y, 3)=I(x, y)+I(x+2, y)+I(x, y+2)+I(x+2, y+2)

We note Z(p) the 4D vector(Z(x, y, k), k ∈ {0,1,2,3}), the filteredvalue is then:

$z = {\frac{1}{C(p)}\Sigma_{q \in {N{(p)}}}{I(q)}{w_{hf}\left( {p,q} \right)}\mspace{14mu} {with}}$C(p) = Σ_(q ∈ N(p))w_(hf)(p, q)N(p) = {p + 2(i, j); Mi, jM}

and with

${w_{hf}\left( {p,q} \right)} = {\exp \left( \frac{- {{{z(p)} - {Z(q)}}}^{2}}{\rho^{2}} \right)}$

where |.| denotes the Euclidean norm.

3.2 Physical Interpretation of the Filter

The action of the filter 218 is modulated by the weights w_(hf) andthose weights decrease with the distances |Z(p)−Z(q)|. Now thosedistances are based on Z which is box filtered. This box filtering makesthe distance insensitive to Nyquist frequency. So the modulation of thefilter 218 ignores the highest frequency. This explain why medium andlower frequencies are preserved while higher frequencies are filteredmore strongly. The filter 218 needs to be used with a strength typicallylower than the previous denoiser, because otherwise all details in thehighest frequencies are lost.

3.3 Ranges for Parameters

For parameter ρ we consider two cases:

Case A. Input image had Anscombe transform applied and the filter isapplied before the inverse Anscombe transform.

Case B. Anscombe transform is not used and input image normalized in [0,1].

3.3.1 Preferred Ranges

In some preferred embodiments a value of M is chosen from a range ofabout 1 to 2. Provided an Anscombe transform has been applied to the rawimage 104 (Case A), a value of ρ is chosen from a range of 0.003 to0.03; otherwise (Case B) a value of ρ is chosen from a range of 0.0001to 0.001.

3.3.2 Other Preferred Ranges

In other preferred embodiments a value of M is chosen from a range ofabout 1 to 2. Provided an Anscombe transform has been applied to the rawimage 104 (Case A), a value of ρ is chosen from a range of 0.001 to0.05; otherwise (Case B) a value of ρ is chosen from a range of 0.0001to 0.003.

3.3.3 Still Other Preferred Ranges

In other preferred embodiments a value of M is chosen from a range ofabout 1 to 4. Provided an Anscombe transform has been applied to the rawimage 104 (Case A), a value of ρ is chosen from a range of 0.001 to 0.1;otherwise (Case B) a value of ρ is chosen from a range of 0.0001 to0.01.

4.0 Demosaic Artifact Suppression in Digital Images

A system 400 for demosaic artifact suppression in digital images ofanother embodiment of the invention is shown in FIG. 4. The system 400of FIG. 4 is similar to the system 100 of FIG. 1, except for theadditional Demosaic Module 402, and the Demosaic Artifact SuppressionModule 406 replacing the CFA Pattern Aware Denoising Module 106, andreference numerals in FIG. 4 are repeated from FIG. 1 for illustratingsimilar elements.

The system 100 comprises a Raw Image Acquisition Device 112, for examplea digital camera, image scanner or motion picture film scannercomprising an image sensor device 114 such as CCD or CMOS image sensor,for acquiring a raw image 104. The raw image 104 contains minimallyprocessed data from the image sensor 114, in a raw image format.

The acquired raw image 104 is supplied to an Image Processing Module 102comprising a Demosaic Module 402, outputting a demosaiced image 404, anda Demosaic Artifact Suppression Module 406 for processing the demosaicedimage 404 into a corrected image 408.

The Image Processing Module 102, the Demosaic Module 402 and theDemosaic Artifact Suppression Module 406 are stored in a memory device118 and comprise computer executable instructions stored in the memorydevice 118 for execution by a hardware processor 110. The DemosaicArtifact Suppression Module 406 outputs the corrected image 408 througha Corrected Image Output Module 410 which contains computer readableinstructions stored in a memory (not shown) and is responsible forstorage or further processing of the corrected image 408 or transmissionof the corrected image 408 over a network.

FIG. 5 shows the Demosaic Artifact Suppression Module 406 of FIG. 4 inmore detail. In the embodiment of the invention, the CFA is a Bayer'sfilter.

The Demosaic Artifact Suppression Module 406 comprises a Pixel SelectionModule 502 for selecting a pixel of interest for processing, and anImproved Cross Bilateral Filter 504, which is a guided filter. TheImproved Cross Bilateral Filter 504 comprises a Guide DeterminationModule 506 for determining a guide, or a special image, for applying inthe Improved Cross Bilateral Filter 504 of the embodiment of theinvention, and a Pixel Processing Module 514 using the determined guide.

The Guide Determination Module 506 comprises a module for selecting 2×2blocks of pixels containing a pixel “p” of interest; a Module foraveraging the luminance of the selected 2×2 blocks of pixels 510; and aModule for forming the guide as a four channel image 512.

In the embodiment of the invention, assuming that a Bayer's filter isused for the acquisition of the raw image 104, there will be four blocksof 2×2 pixels which contain the pixel “p” of interest.

Denoting p1, p2, p3, p4, p5, p6, p7 and p8 pixels neighboring the pixel“p” of interest, and Y(q) the luminance of any pixel q, we can definethe computation of the 4-dimensional component of the Guide for thepixel “p” as presented in Tables 3A, 3B, 3C, and 3D below:

An average luminance for each of these four blocks of 2×2 pixels(corresponding to the pixel “p” pf interest) is determined (L1p, L2p,L3p and L4p), and the values of the average luminance for these blocksare used as component of a 4-dimensional vector.

The same procedure is repeated for all pixels in the demosaiced image,forming a 4-channel image, or a 4-dimensional vector with components(L1p, L2p, L3p, L4p) for each pixel, thus forming a Guide for use in theguided Improved Cross Bilateral Filter 504.

It should be noted that rather than the average luminance, the sum ofthe luminances could be used as effectively.

It is understood that other types of CFA are also possible, and theCross Bilateral Filter may be substituted by Non-Local Means filter oranother filter suitable for processing a demosaiced image. If using afilter other than the cross bilateral, the previously defined guideshould be used for computing the weights between pixels, rather than theimage itself.

The Pixel Selection Module 502, and the Improved Cross Bilateral Filter504 including its modules 506 and 514 comprise computer readableinstructions stored in a memory for execution by the hardware processor110.

The method for demosaic artifact suppression in digital images of theembodiment of the invention is illustrated by a flowchart 600 of FIG. 6.

Upon obtaining the demosaiced image 404 from the Demosaic Module 402,the method selects a pixel “p” in the demosaiced image 404 to process(box 602).

Next, four 2×2 blocks of pixels are selected, containing the pixel “P”of interest (box 604), followed by determining an average luminance foreach of the four selected blocks (box 606), the average luminance foreach of the selected four blocks being designated as L1p, L2p, L3p andL4p.

Next, a 4D component of a 4-dimensional vector is formed, correspondingto the pixel “p”, the 4D component of the 4-dimensional vectorcomprising the average luminance for the selected four blocks (L1p, L2p,L3p, L4p).

Provided the pixel “p” is not the last pixel in the demosaiced image 404(exit “No” from box 610), the method returns back to the box 602 forprocessing the next pixel.

Provided the pixel “p” is the last pixel in the demosaiced image 404(exit “Yes” from box 610), the method proceeds to determining animproved Guide of the embodiment of the invention (box 612), which is acomplete 4-dimensional vector comprising multiple 4D components,corresponding to individual pixels in the demosaiced image 404. We willalso refer to the 4-dimensional vector as a 4-channel image, or also asan image Guide, to be used in a guided Cross Bilateral Filter asdescribed below.

The improved Guide of the embodiment of the invention, which has beendetermined in box 612, is used in the Cross Bilateral Filter (box 614),which is applied to the demosaiced image 404 (box 614).

The guided Cross Bilateral Filter with the improved Guide outputs thecorrected image 408 through the Corrected Image Output Module 410 (box616), followed by the termination of the method.

4.1 Method for Demosaic Artifact Suppression

The method for demosaic artifact suppression of the embodiment of theinvention has been described assuming that the pattern of the colorfilter array is 2 pixels by 2 pixels square, and the image has 3 colorchannels, red, green and blue. This is the case for instance for theBayer pattern filter.

Let I=(I_(R),I_(G),I_(B)) be the demosaiced color image 404 to correctfor demosaicing artifacts and Y its luminance.

For any pixel p=(x,y) we define:

Z(x,y,0)=Y(x,y)+Y(x−1,y)+Y(x,y−1)+Y(x−1,y−1)

Z(x,y,1)=Y(x,y)+Y(x+1,y)+Y(x,y−1)+Y(x+1,y−1)

Z(x,y,2)=Y(x,y)+Y(x−1,y)+Y(x,y+1)+Y(x−1,y+1)

Z(x,y,3)=Y(x,y)+Y(x+1,y)+Y(x,y+1)+Y(x+1,y+1)

For any pixel p=(x,y), we note Z(p) the 4D vector (Z(x,y,k), k ∈{0,1,2,3}) Z is the improved guide of the embodiment of the invention,which is used for performing a cross bilateral filtering on thedemosaiced image 121. The coefficients/components of the vector Z(p) arethe average luminance of each of the four 2×2 blocks that contain thepixel p.

The RGB image is then filtered with a cross bilateral filter or any ofits variations, guided with the 4 channel image Z. Further details areprovided below.

Let I_(i)(p) be the intensity value at pixel p for the channel i ∈ {R,G, B}.

Let Î be the filtered image. Then for each pixel p, for each colorchannel i ∈ {R, G, B}, the value of the filtered image at pixel p andfor channel i is defined as follows:

${{\hat{I}}_{i}(p)} = {\frac{1}{W_{p}}{\sum\limits_{q \in {P{(I)}}}\; {{w\left( {p,q} \right)}{I_{i}(q)}}}}$

where:

-   -   P(I) is the set of all pixels in the image.    -   w(p,q)=r_(Z)(p,q) s(p,q) is the weight of pixel q to filter        pixel p.    -   r_(Z) is the range kernel, guided by Z. It measures the        similarity of the features in the guide Z for pixels p and q,        usually it is takes the following form:

${r_{Z}\left( {p,q} \right)} = {{\exp \left( {- \frac{{{{Z(p)} - {Z(q)}}}^{2}}{\rho^{2}}} \right)}.}$

-   -   s is the space kernel. It measures how close in space in the        image the pixels p and q are. Usually it is chosen as:

${{s\left( {p,q} \right)} = {\exp \left( {- \frac{{{p - q}}^{2}}{\sigma^{2}}} \right)}},$

-   -   another common choice is the step function:        s(p,q)=δ(|x_(p)−x_(q)|<k) δ(|y_(p)−y_(q)|<k), where        p=(x_(p),y_(p)) and q=(x_(q),y_(q)), which is equal to 1 when        |x_(p)−x_(q)|<k and |y_(p)−y_(q)|<k, and equal to 0 otherwise.

$W{\sum\limits_{p = {q \in {P{(I)}}}}\; {w\left( {p,q} \right)}}$

-   -   is a normalizing factor.

Remarks:

1. Assuming the range of the image is [0,1], typical values for theparameters above are: ρ=5·10⁻⁴, σ=4, k=4, which may be tunedappropriately for better results depending on the input.

2. The summation over q ∈ P(I) above can be simplified in practice to asmaller domain q ∈ B(p), where B(p)={q=p+(x,y) | −b<x,y<b} with b=3σ orb=k depending on which space kernel s is chosen.

3. Any fast implementation of the bilateral filter, or variations aroundthe bilateral filter, that allows to do guided filtering, can be used tocompute Î. The only requirement is that the 4 channel image Z definedabove is used as the guide. Examples of such fast implementationsinclude: the bilateral grid described in “Real-Time Edge-Aware ImageProcessing With The Bilateral Grid,” J. Chen, S. Paris, and F. Durand,ACM Transactions on Graphics (Proc. SIGGRAPH 07), page 103, 2007, thepermutohedral lattice described in “Fast High-Dimensional FilteringUsing The Permutohedral Lattice,” A. Adams, J. Baek, and M. A. Davis,Computer Graphics Forum (Proc. Eurographics), 2010, the Gaussiankd-trees filter described in “Gaussian Kd-Trees For FastHigh-Dimensional Filtering,” A. Adams, N. Gelfand, J. Dolson, and M.Levoy, ACM Transactions on Graphics (Proc. SIGGRAPH 09), pages 1-12,2009, the domain transform recursive filter described in “DomainTransform For Edge-Aware Image And Video Processing,” E. S. L. Gastal,M. M. Oliveira. ACM TOG 30, 4 (2011), 69:1-69:12 the adaptive manifoldfilter described in “Adaptive Manifolds For Real-Time High-DimensionalFiltering,” E. S. L. Gastal, M. M. Oliveira, ACM TOG 31, 4 (2012),33:1-33:13. Proceedings of SIGGRAPH 2012.

Thus, an improved method and system for demosaic artifact suppression indigital image have been provided.

5.0 Edge Denoising

We now describe the edge denoising module 220 of FIG. 2. The edgedenoising module 220 denoises strong edges on the raw image 104. It ismeant to be run in parallel with the texture preserving raw imagedenoiser described above. Then the results of the two filters areblended together in a way described below.

For each pixel p, the edge denoising algorithm takes the followingsteps:

-   -   1. Estimate the normal to the edge. (details later)    -   2. Compute the blurred edge denoised value z at pixel p as the        result of a 1D Gaussian filter centered on p using neighboring        pixels projected to the normal to the edge. (details later)    -   3. Compute the blurred edge denoised shifted values z⁻ and z₊ as        in the previous step but with the 1D Gaussian filter centered on        each of the 2 points located on the normal to the edge at a        distance h of the pixel p. (details later)    -   4. Compute an approximate second order derivative, at scale h,        along the normal to the edge: Δ=2z−z_(l)−z_(r)    -   5. Compute the sharpened edge denoised value at pixel p,        z_(sharp)=z+sΔ, s is the strength of the sharpening.    -   6. Compute minimum and maximum: z_(min)=min{z, z⁻, z₊} and        z_(max)=max{z, z⁻, z₊}    -   7. Compute the final sharpened edge denoised value with halo        removal:

(p)=min(max(z _(sharp) , z _(min)),z _(max))

Remarks:

-   -   The 1D Gaussian filter of step 2 is parameterized by a standard        deviation σ which can be increased to get stronger denoising and        conversely (a typical value would be 1.5 or 2).    -   The parameters h and s appearing at steps 3 and 5 are parameters        of the edge denoising filter to be chosen.    -   The filtering done at step 2 creates some amount of blur in z.        The subsequent steps act as a sharpener. That sharpening effect        can be limited to just cancel the blur introduced at step 2, or        go even further and produce a sharpened denoised edge.        Increasing h and s increases the sharpening effect and        conversely. Example of values that would cancel the blur        introduced at step 2 but not increase sharpness are h=2 and        s=0.6.    -   The sharpened edge denoised value z_(sharp)may produce black or        white halos around the edge, the steps 6 and 7 mitigate this        undesirable effect.

5.1. Estimation of the Normal to the Edge

The normal to the edge is estimated with the help of the followinglinear filters.

$\begin{matrix}{K_{x} = \begin{bmatrix}{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & 0 & {- 1} & 0 & 0 & 0 & 0 & 0 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1\end{bmatrix}} & \; \\{K_{y} = \begin{bmatrix}{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & {- 1} & {- 1} & {- 1} & {- 1} \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & {- 1} & {- 1} & {- 1} & {- 1} \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\1 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 1 \\1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\1 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 1 \\1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\end{bmatrix}} & \; \\{K_{z} = \begin{bmatrix}0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\{- 1} & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0\end{bmatrix}} & \; \\{K_{w} = \begin{bmatrix}{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 & 1 & 1 & 1 & 1 \\{- 1} & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\end{bmatrix}} & \;\end{matrix}$

The raw image is filtered with each of those filters producing imagesd_(x), d_(y), d_(z)and d_(w) respectively. Then two estimates of thenormal to the edge are computed, with d_(x) and d_(y) on one hand andwith d_(z) and d_(w) on the other hand, represented by the complexnumbers g_(xy) and g_(zw) respectively: g_(xy)=d_(x)+id_(y) and

$g_{zw} = {\left( {d_{z} + {id}_{w}} \right)e^{{- i}\; \frac{\pi}{4}}}$

(where i=√{square root over (−1)}). Those two estimates are normalizedand averaged to g=0.5 (g_(xy)/|g_(xy)|+g_(zw)/|g_(zw)|) and finally theestimate of the unit vector normal to the edge

${isu} = {\frac{\overset{\_}{g}}{\overset{\_}{g}}.}$

Remarks:

-   -   The size of the filters given here is 9, but a larger size could        be used in the case of very low light (i.e. very high noise), to        make the estimate more robust, as long as the filter follows the        pattern given here. Conversely a smaller size could be used in        the case of moderate noise. Large filters are more robust to        noise but computationally more expensive and are less accurate        in the case of edges with high curvature.    -   There are 0 values every other coefficient in the central row of        K_(x) and in the central column of K_(y) which may look        surprising. The reason is if we do not put zero weight at those        coefficients then for some color channel the two filters would        put non zero weight to a different number of pixels. It is        important that for each color channel the number of pixels with        non zero weight is the same for both filter, otherwise the        estimate of the direction will be biased because the average        intensity may be different from one channel to another.

Here is a visualization of that property with filters of size 5, appliedto a green pixel:

$K_{x}^{(b)} = {{\begin{bmatrix}{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1\end{bmatrix}K_{y}^{(b)}} = \begin{bmatrix}{- 1} & {- 1} & {- 1} & {- 1} & {- 1} \\{- 1} & {- 1} & {- 1} & {- 1} & {- 1} \\0 & 0 & 0 & 0 & 0 \\1 & 1 & 1 & 1 & 1 \\1 & 1 & 1 & 1 & 1\end{bmatrix}}$ $K_{x} = {{\begin{bmatrix}{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & 0 & 0 & 0 & 1 \\{- 1} & {- 1} & 0 & 1 & 1 \\{- 1} & {- 1} & 0 & 1 & 1\end{bmatrix}K_{y}} = \begin{bmatrix}{- 1} & {- 1} & {- 1} & {- 1} & {- 1} \\{- 1} & {- 1} & 0 & {- 1} & {- 1} \\0 & 0 & 0 & 0 & 0 \\1 & 1 & 0 & 1 & 1 \\1 & 1 & 1 & 1 & 1\end{bmatrix}}$

Here K_(x) ^((b)) put non-zero weight to 4 blue pixels and 6 red pixelswhile K_(y) ^((b)) put non-zero weight to 6 blue pixels and 4 redpixels. With K_(x) and K_(y) for any color channel the number of pixelswith non zero weight is consistent between the two filters. Finally wedo not need to put every other coefficient to zero in the diagonals ofK_(w) and K_(z) because they readily satisfy the property that for eachcolor channel the number of pixels with non-zero weight is the same forboth filter. Moreover, the fact that K_(x) and K_(y) on one hand andK_(w) and K_(z) on the other hand put non-zero weight to a differentnumber of pixels for some color channel does not matter. The reason isthat their respective estimates g_(xy) and g_(zw) are first normalizedbefore being aggregated.

5.2. Computation of the Blurred Edge Denoised Value z

The blurred edge denoised value z at pixel p is the result of a 1DGaussian filter centered on p using neighboring pixels projected to thenormal to the edge. More precisely the formula to compute z is:

$z = {\frac{1}{C(p)}{\sum_{x = {- k}}^{k}{\sum_{y = {- k}}^{k}{{I\left( {p + {2\left( {x,y} \right)}} \right)}{w_{e}\left( {p,x,y} \right)}}}}}$

with C(p)=Σ_(x=−k) ^(k)Σ_(y=−k) ^(k)w_(e) (p, x, y)

and with

${w_{e}\left( {p,x,y} \right)} = {\exp\left( \frac{- \left( {{xu}_{x} + {yu}_{y}} \right)^{2}}{2\sigma^{2}} \right)}$

where (u_(x), u_(y))=u is the normal to the edge at pixel p estimatedpreviously. The term (xu_(x)+yu_(y))² is the square of the distancebetween point p+2(x, y) and the edge. The size of the support of thefilter is 4k +1, k is chosen depending on the desired amount ofdenoising and the computational budget. When k is larger the denoisingis stronger but can accommodate only less curved edges and it requiresmore computations.5.3. Computation of the Blurred Edge Denoised Shifted Values z⁻ and z₊

The formulas to compute z⁻ and z₊ are:

$z_{-} = {\frac{1}{C_{-}(p)}{\sum\limits_{x = {- k}}^{k}{\sum\limits_{y = {- k}}^{k}{{I\left( {p + {2\left( {x,y} \right)}} \right)}{w_{-}\left( {p,x,y} \right)}}}}}$with${C_{-}(p)} = {\sum\limits_{x = {- k}}^{k}{\sum\limits_{y = {- k}}^{k}{w_{-}\left( {p,x,y} \right)}}}$$z_{+} = {\frac{1}{C_{+}(p)}{\sum\limits_{x = {- k}}^{k}{\sum\limits_{y = {- k}}^{k}{{I\left( {p + {2\left( {x,y} \right)}} \right)}{w_{+}\left( {p,x,y} \right)}}}}}$with${C_{+}(p)} = {\sum\limits_{x = {- k}}^{k}{\sum\limits_{y = {- k}}^{k}{w_{+}\left( {p,x,y} \right)}}}$and  with${w_{-}\left( {p,x,y} \right)} = {\exp\left( \frac{- \left( {{xu}_{x} + {yu}_{y} - h} \right)^{2}}{2\sigma^{2}} \right)}$and${w_{+}\left( {p,x,y} \right)} = {{\exp\left( \frac{- \left( {{xu}_{x} + {yu}_{y} + h} \right)^{2}}{2\sigma^{2}} \right)}.}$

The term (xu_(x)+yu_(y)−h)² is the square of the distance between thepoint p+2(x, y) and the line parallel to the edge at a distance h on theside of the edge that has the brighter pixels.

The term (xu_(x)+yu_(y)+h)² is the square of the distance between thepoint p+2(x, y) and the line parallel to the edge at a distance h on theside of the edge that has the darker pixels.

5.4. Blending With the Result of the Texture Preserving Raw ImageDenoiser

The following is a description of the functions of the Blending Module222 shown in FIG. 2.

Denoting

(p) the result of the texture preserving denoiser and

(p) the result of the edge denoiser, the final estimate of the denoisedimage is:

(p)=w _(b)(p)

(p)+(1−w _(b)(p))

(p)

where is a blending weight at each pixel p which is computedautomatically the following way.

w _(b)(p)=(1−sig(α(p),μ_(α)))(1−sig(m(p),μ_(g)))

sig is the following sigmoid function:

${{sig}\left( {x,\mu} \right)} = {0.5{\tanh \left( {4\; \frac{x - \mu}{\min \left( {{\mu },\varepsilon} \right)}} \right)}}$

where ∈ is some small value to avoid division by 0.

The constants μ_(α) and μ_(g) are parameters to tune to obtain bestblending results. Typical values are μ_(α)∈[5,15] and μ_(g)=1.3.

The function α(p) measures the variability in a small neighborhood of pof the direction of u, the normal to the edge, as estimated previously.The function m(p) measures how much the neighborhood of p is similar toa patch with a strong edge separating two flat areas. It does this byestimating the absolute value of the derivatives along many differentdirections and taking the minimum of those. Both α(p) and m(p) tend tobe high when p is not close to an edge and are close to zero when p isclose to a strong edge. This makes w_(b) (p) close to 0 when p is notclose to an edge and close to 0 when p is close to a strong edge ifμ_(α) and μ_(g) are well chosen.

We now give details about how to compute α(p) and m(p).

5.4.1. Computation of α(p)

We introduce the following notations: N(p)={p+(x, y); x, y ∈ {−2,0,2}}aneighborhood of p that includes p and 8 other nearby pixels of the sameBayer channel, and θ(p)=angle(u) the angle of the normal to the edge atp. For q, q′ ∈ N(p) we define δ(q, q′)=(θ(q)−θ(q′))≡π where the symbol ≡means modulo. Then

${\alpha (p)} = {\frac{180}{\pi}{\min\limits_{q,{q^{\prime} \in {N{(p)}}}}{\alpha \left( {q,q^{\prime}} \right)}}}$

where α(q, q′)=min(δ(q, q′), π−δ(q, q′)). The scaling by

$\frac{180}{\pi}$

is optional, it is useful to be able to express μ_(a) in degrees.5.4.2. Computation of m(p)

We present two methods to compute m(p). The first method is based onfilters with small support which is advantageous when using line bufferarehitectures, but that method can become inaccurate in case of verysharp images. For such cases we present a second method based on filterswith larger support.

5.4.2.1. Method 1: Small Support Filters

We first define g_(x) and g_(y) as the convolutions of the input rawimage I with kernels k_(x)=(−1 0 1) and k_(y)=k_(x) ^(T) respectively.Then for any θ ∈ [0, π] and pixel p in the image, we define g(p,θ)=|g_(x)(p)cosθ+g_(y)(p)sinθ| and

${\overset{\_}{g}\left( {p,\theta} \right)} = {\frac{1}{{B(p)}}{\sum_{q \in {B{(p)}}}{g\left( {q,\theta} \right)}}}$

where B(p) is a neighborhood of p, for instance all pixels in a patch ofM by M pixels centered at p. Then m(p) is defined as follows:

${m(p)} = {\min\limits_{k \in {\{{1,\ldots \mspace{14mu},N}\}}}{\overset{\_}{g}\left( {p,{\frac{k}{N}\pi}} \right)}}$

where N is chosen such as making the filter effective enough atmeasuring the similarity of the patch with a strong edge, while stillbeing acceptable in terms of amount of computation.

5.4.2.2. Method 2: Large Support Filters

We first define a collection of 16 filters K=(k_(i); i ∈ {1, . . . ,16})as follows.

${k_{1} = \begin{pmatrix}{- 1} & 0 & 1\end{pmatrix}},{k_{2} = k_{1}^{T}},{k_{3} = \begin{pmatrix}{- 1} & 0 & 0 \\0 & 0 & 0 \\0 & 0 & 1\end{pmatrix}},{k_{4} = \begin{pmatrix}0 & 0 & 1 \\0 & 0 & 0 \\{- 1} & 0 & 0\end{pmatrix}}$ ${k_{5} = \begin{pmatrix}{- 1} & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 1\end{pmatrix}},{k_{6} = k_{5}^{T}},{k_{7} = \begin{pmatrix}0 & 0 & 0 & 0 & 1 \\0 & 0 & 0 & 0 & 0 \\{- 1} & 0 & 0 & 0 & 0\end{pmatrix}},{k_{8} = k_{7}^{T}}$ ${k_{9} = {0.25\begin{pmatrix}{- 3} & 0 & 0 & 0 & 1 \\0 & 0 & 0 & 0 & 0 \\{- 1} & 0 & 0 & 0 & 3\end{pmatrix}}},{k_{10} = k_{9}^{T}},{k_{11} = {0.25\begin{pmatrix}{- 1} & 0 & 0 & 0 & 3 \\0 & 0 & 0 & 0 & 0 \\{- 3} & 0 & 0 & 0 & 1\end{pmatrix}}},{k_{12} = k_{11}^{T}}$ ${k_{13} = {0.25\begin{pmatrix}{- 3} & 0 & {- 1} & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 1 & 0 & 3\end{pmatrix}}},{k_{14} = k_{13}^{T}},{k_{15} = {0.25\begin{pmatrix}0 & 0 & {- 1} & 0 & {- 3} \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 \\3 & 0 & 1 & 0 & 0\end{pmatrix}}},{k_{16} = {k_{15}^{T}.}}$

Then for each k ∈ K we define g _(k) as the convolution of the input rawimage I with kernel k, and

${{\overset{\_}{g}}_{k}(p)} = {\frac{1}{{B(p)}}{\sum_{q \in {B{(p)}}}{{g_{k}(q)}}}}$

where B(p) is a neighborhood of p as previously. Then m(p) is defined asfollows:

${m(p)} = {\min\limits_{k \in K}{{{\overset{\_}{g}}_{k}(p)}.}}$

6.0 Modifications/Variations

The systems 100 and 100 of the embodiments of the invention, comprisingall modules and devices as described with regard to FIGS. 1, 2, 4 and 5include memory devices having computer readable instructions storedtherein, for execution by at least one hardware processor.

It should be noted that image input data and image output data of thesystem and method of the embodiments of the present invention describedherein are not, in any sense, abstract or intangible.

Instead, the data is necessarily digitally encoded and stored in aphysical data-storage computer-readable non-transitory storage medium,such as an electronic memory, mass-storage device, or other physical,tangible, data-storage device and medium.

It should also be noted that the currently described data-processing anddata-storage methods cannot be carried out manually by a human analyst,because of the complexity and vast numbers of intermediate resultsgenerated for processing and analysis of even quite modest amounts ofdata.

Instead, the methods described herein are necessarily carried out byelectronic computing systems on electronically or magnetically storeddata, with the results of the data processing and data analysisdigitally encoded and stored in one or more tangible, physical,data-storage devices and media.

In the method and system for denoising of a digital image, a bilateralfilter, which does not use a guide but instead uses the image itself forcomputing the weights, may be used instead of non local means filter.However, the bilateral filter usually yields inferior results comparedwith the non local means filter for denoising applications.

The raw image format of the embodiments of the invention has beenacquired using a Bayer's filter, however it is understood that any otherraw image format of existing manufacturers of digital equipment may bealso used, such as CYGM (cyan, yellow, green, magenta) filter, RGBE(red, green, blue, emerald) filter, panchromatic cell filters of variousconfigurations, including CMYW (cyan, magenta, yellow, and white)filter, RGBW (red, green, blue, white) filter and other panchromaticfilters; Fuji film “EXR” color filter array, Fuji film “X-Trans” colorfilter or else.

Although a single hardware processor 102 has been shown in FIG. 1 and asingle hardware processor has been shown in FIG. 4, it is understoodthat the processing of images according to the embodiments of thepresent invention may be performed by multiple processors or cores,either sequentially or in parallel. Also certain parts of the processingor the entire processing may be done in a cloud, if required.

The method for demosaic artifact suppression of the present inventionmay be generalized for images with arbitrary set of channels, forinstance: red, green, blue, and infrared. To do so, we need to performthe weighted average for each of the considered channels in the set ofchannels, as we presented for the R, G, and B channels above.

The method for demosaic artifact suppression of the present inventionmay be also be generalized for other color filter array (CFA) patterns.For example, the vector Z(p) at pixel p may be computed in the followingway. On each sub-set of pixels that has the same shape as the CFApattern and that contains the pixel p, we compute the average luminanceon that set. Those averages form the components of the vector Z(p).

Methods of the embodiment of the invention may be performed using one ormore hardware processors, executing processor-executable instructionscausing the hardware processors to implement the processes describedabove. Computer executable instructions may be stored inprocessor-readable storage media such as floppy disks, hard disks,optical disks, Flash ROMs (read only memories), non-volatile ROM, andRAM (random access memory). A variety of processors, such asmicroprocessors, digital signal processors, and gate arrays, may beemployed.

Systems of the embodiments of the invention may be implemented as any ofa variety of suitable circuitry, such as one or more microprocessors,digital signal processors (DSPs), application-specific integratedcircuits (ASICs), field programmable gate arrays (FPGAs), discretelogic, software, hardware, firmware or any combinations thereof. Whenmodules of the systems of the embodiments of the invention areimplemented partially or entirely in software, the modules contain amemory device for storing software instructions in a suitable,non-transitory computer-readable storage medium, and softwareinstructions are executed in hardware using one or more processors toperform the methods of this disclosure.

It should be noted that methods and systems of the embodiments of theinvention and data streams described above are not, in any sense,abstract or intangible. Instead, the data is necessarily presented in adigital form and stored in a physical data-storage computer-readablemedium, such as an electronic memory, mass-storage device, or otherphysical, tangible, data-storage device and medium. It should also benoted that the currently described data-processing and data-storagemethods cannot be carried out manually by a human analyst, because ofthe complexity and vast numbers of intermediate results generated forprocessing and analysis of even quite modest amounts of data. Instead,the methods described herein are necessarily carried out by electroniccomputing systems having processors on electronically or magneticallystored data, with the results of the data processing and data analysisdigitally stored in one or more tangible, physical, data-storage devicesand media.

Although specific embodiments of the invention have been described indetail, it should be understood that the described embodiments areintended to be illustrative and not restrictive. Various changes andmodifications of the embodiments shown in the drawings and described inthe specification may be made within the scope of the following claimswithout departing from the scope of the invention in its broader aspect.

What is claimed is:
 1. A method for denoising a raw digital image,comprising: employing a hardware processor to perform: (a) selecting afirst pixel (p) of the raw digital image; (b) selecting a second pixel(q) of the raw digital image; (c) determining a first plurality of pixelpatches, each pixel patch in the first plurality of pixel having apredetermined pixel patch shape and a predetermined pixel patch size andcontaining the first pixel (p); (d) determining a second plurality ofpixel patches, each pixel patch in the second plurality containing thesecond pixel (q), and corresponding in shape and size to a respectivepixel patch of the first plurality; the first plurality; (e) determininga patch distance between each pair of corresponding pixel patches in thefirst plurality and the second plurality of pixel patches; (f)determining an effective distance between the first pixel (p) and thesecond pixel (q) based on determined patch distances for all pairs ofcorresponding pixel patches in the first plurality and the secondplurality of pixel patches; (g) repeating the steps (a) to (f) for thesame first pixel (p) and another second pixel (q) until a predeterminednumber of pixels (q) in the raw digital image is processed; and (h)denoising the first pixel (p), comprising determining respectivecontributions of the pixels (q) into a noise reduction of the pixel (p),using respective effective distances of the pixels (q).
 2. The method ofclaim 1, comprising repeating the steps (a) to (h) for other firstpixels (p) until a predetermined number of pixels (p) in the raw digitalimage is processed, thereby obtaining a denoised raw digital image. 3.The method of claim 2, wherein: the predetermined number of pixels (q)comprises all pixels (q) in the raw digital image outside of the firstplurality of pixel patches; and the predetermined number of pixels (p)comprises all pixels (p) in the raw digital image outside of the secondplurality of pixel patches.
 4. The method of claim 1, wherein thepredetermined pixel patch shape is one of the following: a square; arectangle; a circle; an oval; a hexagon; an octagon; or a polygon. 5.The method of claim 1, wherein the predetermined pixel patch shape is asquare, and a predetermined pixel patch size is from 2×2 pixels to 3×3pixels.
 6. The method of claim 1, wherein the predetermined pixel patchshape is a square, and a predetermined pixel patch size is from about2×2 pixels to about 8×8 pixels.
 7. The method of claim 1, wherein thepredetermined pixel patch shape is a square, and a predetermined pixelpatch size is from about 5×5 pixels to about 16×16 pixels.
 8. The methodof claim 1, wherein the step (f) comprises determining the effectivedistance as an average patch distance among all patch distances.
 9. Themethod of claim 1, wherein the step (f) comprises determining theeffective distance as a maximum patch distance among all patchdistances.
 10. The method of claim 1, wherein the denoising comprisesapplying one of: a Non-Local Means method; or a Bilateral Filter method.11. The method of claim 1, wherein: the predetermined shape of the pixelpatch is a rectangle; a neighborhood of pixels surrounding the pixel (p)used for denoising the pixel (p) has a rectangular shape; and thedenoising comprising applying an integral images method.
 12. The methodof claim 1, wherein the raw digital image is a Bayer's pattern image.13. The method of claim 1, wherein the steps (a) and (b) compriseselecting the first and second pixels of a same type.
 14. The method ofclaim 1, further comprising removing high frequency artifacts from thefirst pixel (p), comprising: determining an average for each pixel patchin the first plurality of pixels; forming a multi-dimensional guide forthe first pixel (p), comprising the average for the pixel patches ascomponents of the multi-dimensional guide; and applying a BilateralFilter method with the multi-dimensional guide to the first pixel (p),thereby removing the high frequency artifacts.
 15. A system fordenoising a raw digital image, comprising: a processor and anon-transitory computer readable storage medium having computer readableinstructions stored thereon for execution by the processor, causing theprocessor to: (a) select a first pixel (p) of the raw digital image; (b)select a second pixel (q) of the raw digital image; (c) determine afirst plurality of pixel patches, each pixel patch in the firstplurality of pixels having a predetermined pixel patch shape and apredetermined pixel patch size and containing the first pixel (p); (d)determine a second plurality of pixel patches, each pixel patch in thesecond plurality containing the second pixel (q), and corresponding inshape and size to a respective pixel patch of the first plurality; (e)determine a patch distance between each pair of corresponding pixelpatches in the first plurality and the second plurality of pixelpatches; (f) determine an effective distance between the first pixel (p)and the second pixel (q) based on determined patch distances for allpairs of corresponding pixel patches in the first plurality and thesecond plurality of pixel patches; (g) repeat the steps (a) to (f) forthe same first pixel (p) and another second pixel (q) until apredetermined number of pixels (q) in the raw digital image isprocessed; and (h) denoise the first pixel (p), comprising determiningrespective contributions of the pixels (q) into a noise reduction of thepixel (p), using respective effective distances of the pixels (q). 16.The system of claim 15, wherein the instructions cause the processor torepeat the steps (a) to (h) for other first pixels (p) until apredetermined number of pixels (p) in the raw digital image isprocessed, thereby obtaining a denoised raw digital image.
 17. Thesystem of claim 16, wherein: the predetermined number of pixels (q)comprises all pixels (q) in the raw digital image outside of the firstplurality of pixel patches; and the predetermined number of pixels (p)comprises all pixels (p) in the raw digital image outside of the secondplurality of pixel patches.
 18. The system of claim 15, wherein thepredetermined pixel patch shape is one of the following: a square; arectangle; a circle; an oval; a hexagon; an octagon; or a polygon. 19.The system of claim 15, wherein the predetermined pixel patch shape is asquare, and a predetermined pixel patch size is from 2×2 pixels to 3×3pixels.
 20. The system of claim 15, wherein the predetermined pixelpatch shape is a square, and a predetermined pixel patch size is fromabout 2×2 pixels to about 8×8 pixels.
 21. The system of claim 15,wherein the predetermined pixel patch shape is a square, and apredetermined pixel patch size is from about 5×5 pixels to about 16×16pixels.
 22. The system of claim 15, wherein the step (f) comprisesdetermining the effective distance as an average patch distance amongall patch distances.
 23. The system of claim 15, wherein the step (f)comprises determining the effective distance as a maximum patch distanceamong all patch distances.
 24. The system of claim 15, wherein theinstructions cause the processor to apply one of: a Non-Local Meansmethod; or a Bilateral Filter method, to denoise the first pixel (p).25. The system of claim 15, wherein: the predetermined shape of thepixel patch is a rectangle; a neighborhood of pixels surrounding thepixel (p) used for denoising the pixel (p) has a rectangular shape; andthe denoising comprising applying an integral images method.
 26. Thesystem of claim 15, wherein the raw digital image is a Bayer's patternimage.
 27. The system of claim 15, wherein the instructions cause theprocessor to select the first and second pixels of a same type in steps(a) and (b).
 28. The system of claim 15, the instructions further causethe processor to remove high frequency artifacts from the first pixel(p), the instructions cause the processor to: determine an average foreach pixel patch in the first plurality of pixels; form amulti-dimensional guide for the first pixel (p), comprising the averagefor the pixel patches as components of the multi-dimensional guide; andapply a Bilateral Filter method with the multi-dimensional guide to thefirst pixel (p), thereby removing the high frequency artifacts.